#include "linklist.cpp"
#include "string.h"
void split1(LinkNode * &L){
LinkNode *pre,*p,*q;
if(L->next == NULL || L->next->next == NULL)
   return;
int x=L-next->data;
pre=L->next;
p=pre-next;
while(p!=NULL){
if(p->data<x){
    pre->next=p->next;
    p->next=L->next;
    L-next=p;
    p=pre-next;
}
else
{
    pre=p;
    p=pre->next;
}

}


}
void split2(LinkNode *&l){
LinkNode *p=L->next,*r,*r1,*L1;
if (L->next==NULL || L->next->next==NULL)
return;
int x=L->next->data;
r=L;
L1=(LinkNode *)malloc(sizeof(LinkNode));
r1=L1;
while(p!==NULL){
if(p->next<x)
{r->next=p;
r=p;
p=p->next;

}
else
{
    r1->next=p;
    r1=p;
    p=p->next;
}
}
r1->next=NULL;
r->next=L1->next;
free(L1);

}
int main(){
    int d;
    LinkNode *L;
    ELemType a[]="daxgdchaeb";
    int n=strlen(a);
    printf("solution 1\n");
    CreateListR(L,a,n);
    printf("L:");
    DispList(L);
    printf("以首节点值进行划分\n");
    Split1(L);
    printf("L:");
    DispList(L);
    DestroyList(L);
    printf("solution 2\n");
    CreateListR(L,a,n);
    printf("L:");
    DispList(L);
    printf("以首节点值进行划分\n");
    Split2(L);
    printf("L: ");Displist(L);
    DestroyList(L);
    return 1;
}
